<template>
  <div class="app-container">
    <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
      <el-table-column align="center" label='设备ID' width="160">
        <template slot-scope="scope">
          {{scope.row.deviceId}}
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center">
        <template slot-scope="scope">
          {{scope.row.deviceName}}
        </template>
      </el-table-column>
      <el-table-column label="设备类型" align="center">
        <template slot-scope="scope">
          {{scope.row.typeName}}
        </template>
      </el-table-column>
      <!--<el-table-column label="省市区街道" align="center">-->
        <!--<template slot-scope="scope">-->
          <!--{{scope.row.provinceName}},{{scope.row.cityName}},{{scope.row.districtName}},{{scope.row.streetName}}-->
        <!--</template>-->
      <!--</el-table-column>-->
      <!--<el-table-column label="所属社区" align="center">-->
        <!--<template slot-scope="scope">-->
          <!--{{scope.row.unitName}}-->
        <!--</template>-->
      <!--</el-table-column>-->
      <el-table-column label="故障状态" align="center">
        <template slot-scope="scope">
          {{scope.row.failureStateName}}
        </template>
      </el-table-column>
      <el-table-column label="工作状态" align="center">
        <template slot-scope="scope">
          {{scope.row.workingStateName}}
        </template>
      </el-table-column>
      <el-table-column label="满桶时间" align="center">
        <template slot-scope="scope">
          {{scope.row.fullTime}}
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <div v-show="!listLoading" class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page.sync="listQuery.page" :page-sizes="[10,20,30,50]"
                     :page-size="listQuery.size" layout="total, sizes, prev, pager, next, jumper"
                     :total="total">
      </el-pagination>
    </div>
    <!--分页END-->
  </div>
</template>

<script>
  import { getList } from '@/api/device/fullList'

  export default {
    data() {
      return {
        list: null,
        listLoading: true,
        total: null,
        listQuery: {
          id: undefined
        }
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      // 获取列表
      fetchData() {
        this.listLoading = true
        getList(this.listQuery).then(response => {
          this.list = response.data.content
          this.total = response.data.totalElements
          this.listQuery.size = response.data.size
          this.listLoading = false
        })
      },
      handleSizeChange(val) {
        this.listQuery.size = val
        this.fetchData()
      },
      handleCurrentChange(val) {
        this.listQuery.page = val
        this.fetchData()
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .filter-container{
    padding-bottom: 10px;
  }
</style>
